IPL Data Analysis Project¶

In [1]:
import pandas as pd
import plotly.graph_objects as go
import plotly.express as px
import matplotlib.pyplot as plt
In [2]:
data = pd.read_csv("IPL 2022.csv")
In [3]:
data
Out[3]:
match_id date venue team1 team2 stage toss_winner toss_decision first_ings_score first_ings_wkts second_ings_score second_ings_wkts match_winner won_by margin player_of_the_match top_scorer highscore best_bowling best_bowling_figure
0 1 March 26,2022 Wankhede Stadium, Mumbai Chennai Kolkata Group Kolkata Field 131 5 133 4 Kolkata Wickets 6 Umesh Yadav MS Dhoni 50 Dwayne Bravo 3--20
1 2 March 27,2022 Brabourne Stadium, Mumbai Delhi Mumbai Group Delhi Field 177 5 179 6 Delhi Wickets 4 Kuldeep Yadav Ishan Kishan 81 Kuldeep Yadav 3--18
2 3 March 27,2022 Dr DY Patil Sports Academy, Mumbai Banglore Punjab Group Punjab Field 205 2 208 5 Punjab Wickets 5 Odean Smith Faf du Plessis 88 Mohammed Siraj 2--59
3 4 March 28,2022 Wankhede Stadium, Mumbai Gujarat Lucknow Group Gujarat Field 158 6 161 5 Gujarat Wickets 5 Mohammed Shami Deepak Hooda 55 Mohammed Shami 3--25
4 5 March 29,2022 Maharashtra Cricket Association Stadium,Pune Hyderabad Rajasthan Group Hyderabad Field 210 6 149 7 Rajasthan Runs 61 Sanju Samson Aiden Markram 57 Yuzvendra Chahal 3--22
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
69 70 May 22,2022 Wankhede Stadium, Mumbai Hyderabad Punjab Group Hyderabad Bat 157 8 160 5 Punjab Wickets 5 Harpreet Brar Liam Livingstone 49 Harpreet Brar 3--26
70 71 May 24,2022 Eden Gardens, Kolkata Gujarat Rajasthan Playoff Gujarat Field 188 6 191 3 Gujarat Wickets 7 David Miller Jos Buttler 89 Hardik Pandya 1--14
71 72 May 25,2022 Eden Gardens, Kolkata Banglore Lucknow Playoff Lucknow Field 207 4 193 6 Banglore Runs 14 Rajat Patidar Rajat Patidar 112 Josh Hazlewood 3--43
72 73 May 27,2022 Narendra Modi Stadium, Ahmedabad Banglore Rajasthan Playoff Rajasthan Field 157 8 161 3 Rajasthan Wickets 7 Jos Buttler Jos Buttler 106 Prasidh Krishna 3--22
73 74 May 29,2022 Narendra Modi Stadium, Ahmedabad Gujarat Rajasthan Final Rajasthan Bat 130 9 133 3 Gujarat Wickets 7 Hardik Pandya Shubman Gill 45 Hardik Pandya 3--17

74 rows × 20 columns

In [4]:
data.head()
Out[4]:
match_id date venue team1 team2 stage toss_winner toss_decision first_ings_score first_ings_wkts second_ings_score second_ings_wkts match_winner won_by margin player_of_the_match top_scorer highscore best_bowling best_bowling_figure
0 1 March 26,2022 Wankhede Stadium, Mumbai Chennai Kolkata Group Kolkata Field 131 5 133 4 Kolkata Wickets 6 Umesh Yadav MS Dhoni 50 Dwayne Bravo 3--20
1 2 March 27,2022 Brabourne Stadium, Mumbai Delhi Mumbai Group Delhi Field 177 5 179 6 Delhi Wickets 4 Kuldeep Yadav Ishan Kishan 81 Kuldeep Yadav 3--18
2 3 March 27,2022 Dr DY Patil Sports Academy, Mumbai Banglore Punjab Group Punjab Field 205 2 208 5 Punjab Wickets 5 Odean Smith Faf du Plessis 88 Mohammed Siraj 2--59
3 4 March 28,2022 Wankhede Stadium, Mumbai Gujarat Lucknow Group Gujarat Field 158 6 161 5 Gujarat Wickets 5 Mohammed Shami Deepak Hooda 55 Mohammed Shami 3--25
4 5 March 29,2022 Maharashtra Cricket Association Stadium,Pune Hyderabad Rajasthan Group Hyderabad Field 210 6 149 7 Rajasthan Runs 61 Sanju Samson Aiden Markram 57 Yuzvendra Chahal 3--22

The dataset contains all the information needed to summarize the story of IPL 2022 so far. So let’s start by looking at the number of matches won by each team in IPL 2022¶

Number of Matches Won by each Team in IPL 2022¶

In [5]:
figure  = px.bar(data, x = data['match_winner'], title  = "number of matches won in IPL 2022")
figure.show()

So, currently, Gujrat is leading the tournament by winning eight matches. It is an achievement as a new team for Gujrat in IPL. Now let’s see how most of the teams win. Here we will analyze whether most of the teams win by defending (batting first) or chasing (batting second):¶

Number of Matches Won by Defending or Chasing¶

In [6]:
#pie chart
data['won_by'] = data['won_by'].map({'Wickets':'Chasing','Runs': 'Defending'})

won_by = data['won_by'].value_counts()
label = won_by.index
counts = won_by.values

colors = ["red","lightgreen"]

fig = go.Figure(data = [go.Pie(labels = label, values = counts)])
fig.update_layout(title_text = "Number of matches won by Chaseing Or defending")
fig.update_traces(hoverinfo = 'label+percent', textinfo = 'value', textfont_size = 30,
                marker = dict(colors = colors, line = dict(color = 'black', width = 3)))
fig.show()

37 matches are won while chasing the target and 377 matches are won while defending the target.¶

Now let’s have a look at the bowlers with the best bowling figures in most of the matches:¶

Best Bowler¶

In [7]:
figure = px.bar(data, x = data['best_bowling'], title = "best bowler of ipl 2022")
figure.show()

Yuzvendra Chahal having the best bowling figures in IPL 2022¶

Now let’s have a look at the most player of the match awards in IPL 2022¶

In [8]:
figure  = px.bar(data, x = ['player_of_the_match'], title = " Most player of the match" )
figure.show()
In [9]:
figure  = px.bar(data, x = data['player_of_the_match'], title = " Most player of the match" )
figure.show()

So Kuldeep Yadav has won the most player of the match in IPL 2022¶

Now let’s see the top scorers of most IPL 2022.¶

In [10]:
figure = px.bar(data, x = data['top_scorer'], y = data['highscore'], title = "Top scorer of the match")
figure.show()

Jos Buttler is the top scorer of IPL 2022.¶

Let’s analyze it deeply by including the runs scored by the top scorers:¶

In [11]:
figure = px.bar(data, x = data['top_scorer'], y = data['highscore'],
                color = data['highscore'],title = "Top scorer of IPL 2022")
figure.show()
In [ ]:
 
In [ ]: